import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore('counter', () => {
    // 定义 state 属性
    const count = ref(0)

    // 定义 getters
    const doubleCount = computed(() => count.value * 2)

    // 定义 actions 
    const increment = () => {
        count.value++
    }

    // 将方法和属性返回以暴露给外界访问使用
    return {
        count,
        doubleCount,
        increment,
    }
})